/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package parcview;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Timer;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.eclipse.swt.*;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
import parcview.simulation.Algorithm;
/**
 *
 * @author Malte
 */
public class MainFrame 
{
    
    private Display display = null;
    private Shell shell = null;
    private ParcView parcView = null;
    private Button buttonStart;
    private Button buttonStop;
    private Button buttonExit;
    private Button buttonInit;
    private Button buttonReInit;
    private Button buttonStep;
    private Button buttonx05;
    private Button buttonx1;
    private Button buttonx2;
    private Button buttonx5;
    private Button buttonx10;
    private Button buttonx100;
    private Label ta1Label;
    private Label ta2Label;
    private Label te1Label;
    private Label te2Label;
    private Label tbLabel;
    private Label nLabel;
    private Text ta1;
    private Text ta2;
    private Text tb;
    private Text n;
    private Text te1;
    private Text te2;
    
    private Combo chooseAlgoCombo = null;
    
    private Group algo = null;
    private Group input = null;
    private Group control = null;
    private Group speed = null;
    
    
    ArrayList<CarQueueDraw> toDraw = new ArrayList<CarQueueDraw>();
    ArrayList<TrafficLightDraw> toDrawTL = new ArrayList<TrafficLightDraw>();
    
    ParcSimulation test;
    
    CarQueueDraw einfahrt;
    CarQueueDraw parkplatz;
    CarQueueDraw ausfahrt;
    CarQueueDraw baustelle;
    
    TrafficLightDraw einfahrtAmpel = new TrafficLightDraw(228,311);
    TrafficLightDraw ausfahrtAmpel = new TrafficLightDraw(340,311);
    
    ArrayList<Point> waitingPointsEinfahrt = new ArrayList<Point>();
    ArrayList<Point> waitingPointsParplatz = new ArrayList<Point>();
    ArrayList<Point> waitingPointsAusfahrt = new ArrayList<Point>();
    ArrayList<Point> waitingPointsBaustelle = new ArrayList<Point>();
    
    Timer t;
    
    public MainFrame() throws FileNotFoundException, IOException {
          
        createShell();     
            

        waitingPointsEinfahrt.add(new Point(94,252));
        waitingPointsEinfahrt.add(new Point(94,292));
        waitingPointsEinfahrt.add(new Point(94,330));
        waitingPointsEinfahrt.add(new Point(94,366));
        waitingPointsEinfahrt.add(new Point(94,408));
        waitingPointsEinfahrt.add(new Point(158,434));
        waitingPointsEinfahrt.add(new Point(201,434));
        
        waitingPointsParplatz.add(new Point(540,587));
        waitingPointsParplatz.add(new Point(540,557));
        waitingPointsParplatz.add(new Point(540,527));
        waitingPointsParplatz.add(new Point(540,497));
        waitingPointsParplatz.add(new Point(540,467));
        waitingPointsParplatz.add(new Point(540,437));
        waitingPointsParplatz.add(new Point(540,407));
        waitingPointsParplatz.add(new Point(540,377));
        waitingPointsParplatz.add(new Point(540,347));
        waitingPointsParplatz.add(new Point(540,317));
        waitingPointsParplatz.add(new Point(540,287));
        waitingPointsParplatz.add(new Point(540,257));
        
        waitingPointsParplatz.add(new Point(580,587));
        waitingPointsParplatz.add(new Point(580,557));
        waitingPointsParplatz.add(new Point(580,527));
        waitingPointsParplatz.add(new Point(580,497));
        waitingPointsParplatz.add(new Point(580,467));
        waitingPointsParplatz.add(new Point(580,437));
        waitingPointsParplatz.add(new Point(580,407));
        waitingPointsParplatz.add(new Point(580,377));
        waitingPointsParplatz.add(new Point(580,347));
        waitingPointsParplatz.add(new Point(580,317));
        waitingPointsParplatz.add(new Point(580,287));
        waitingPointsParplatz.add(new Point(580,257));
        
        waitingPointsParplatz.add(new Point(620,587));
        waitingPointsParplatz.add(new Point(620,557));
        waitingPointsParplatz.add(new Point(620,527));
        waitingPointsParplatz.add(new Point(620,497));
        waitingPointsParplatz.add(new Point(620,467));
        waitingPointsParplatz.add(new Point(620,437));
        waitingPointsParplatz.add(new Point(620,407));
        waitingPointsParplatz.add(new Point(620,377));
        waitingPointsParplatz.add(new Point(620,347));
        waitingPointsParplatz.add(new Point(620,317));
        waitingPointsParplatz.add(new Point(620,287));
        waitingPointsParplatz.add(new Point(620,257));
        
        waitingPointsParplatz.add(new Point(660,587));
        waitingPointsParplatz.add(new Point(660,557));
        waitingPointsParplatz.add(new Point(660,527));
        waitingPointsParplatz.add(new Point(660,497));
        waitingPointsParplatz.add(new Point(660,467));
        waitingPointsParplatz.add(new Point(660,437));
        waitingPointsParplatz.add(new Point(660,407));
        waitingPointsParplatz.add(new Point(660,377));
        waitingPointsParplatz.add(new Point(660,347));
        waitingPointsParplatz.add(new Point(660,317));
        waitingPointsParplatz.add(new Point(660,287));
        waitingPointsParplatz.add(new Point(660,257));
        
        waitingPointsParplatz.add(new Point(700,587));
        waitingPointsParplatz.add(new Point(700,557));
        waitingPointsParplatz.add(new Point(700,527));
        waitingPointsParplatz.add(new Point(700,497));
        waitingPointsParplatz.add(new Point(700,467));
        waitingPointsParplatz.add(new Point(700,437));
        waitingPointsParplatz.add(new Point(700,407));
        waitingPointsParplatz.add(new Point(700,377));
        waitingPointsParplatz.add(new Point(700,347));
        waitingPointsParplatz.add(new Point(700,317));
        waitingPointsParplatz.add(new Point(700,287));
        waitingPointsParplatz.add(new Point(700,257));
        
        waitingPointsParplatz.add(new Point(740,587));
        waitingPointsParplatz.add(new Point(740,557));
        waitingPointsParplatz.add(new Point(740,527));
        waitingPointsParplatz.add(new Point(740,497));
        waitingPointsParplatz.add(new Point(740,467));
        waitingPointsParplatz.add(new Point(740,437));
        waitingPointsParplatz.add(new Point(740,407));
        waitingPointsParplatz.add(new Point(740,377));
        waitingPointsParplatz.add(new Point(740,347));
        waitingPointsParplatz.add(new Point(740,317));
        waitingPointsParplatz.add(new Point(740,287));
        waitingPointsParplatz.add(new Point(740,257));
        
        waitingPointsParplatz.add(new Point(780,587));
        waitingPointsParplatz.add(new Point(780,557));
        waitingPointsParplatz.add(new Point(780,527));
        waitingPointsParplatz.add(new Point(780,497));
        waitingPointsParplatz.add(new Point(780,467));
        waitingPointsParplatz.add(new Point(780,437));
        waitingPointsParplatz.add(new Point(780,407));
        waitingPointsParplatz.add(new Point(780,377));
        waitingPointsParplatz.add(new Point(780,347));
        waitingPointsParplatz.add(new Point(780,317));
        waitingPointsParplatz.add(new Point(780,287));
        waitingPointsParplatz.add(new Point(780,257));
        
        waitingPointsParplatz.add(new Point(820,587));
        waitingPointsParplatz.add(new Point(820,557));
        waitingPointsParplatz.add(new Point(820,527));
        waitingPointsParplatz.add(new Point(820,497));
        waitingPointsParplatz.add(new Point(820,467));
        waitingPointsParplatz.add(new Point(820,437));
        waitingPointsParplatz.add(new Point(820,407));
        waitingPointsParplatz.add(new Point(820,377));
        waitingPointsParplatz.add(new Point(820,347));
        waitingPointsParplatz.add(new Point(820,317));
        waitingPointsParplatz.add(new Point(820,287));
        waitingPointsParplatz.add(new Point(820,257));
        
        waitingPointsParplatz.add(new Point(860,587));
        waitingPointsParplatz.add(new Point(860,557));
        waitingPointsParplatz.add(new Point(860,527));
        waitingPointsParplatz.add(new Point(860,497));
        waitingPointsParplatz.add(new Point(860,467));
        waitingPointsParplatz.add(new Point(860,437));
        waitingPointsParplatz.add(new Point(860,407));
        waitingPointsParplatz.add(new Point(860,377));
        waitingPointsParplatz.add(new Point(860,347));
        waitingPointsParplatz.add(new Point(860,317));
        waitingPointsParplatz.add(new Point(860,287));
        waitingPointsParplatz.add(new Point(860,257));
        
        waitingPointsParplatz.add(new Point(900,587));
        waitingPointsParplatz.add(new Point(900,557));
        waitingPointsParplatz.add(new Point(900,527));
        waitingPointsParplatz.add(new Point(900,497));
        waitingPointsParplatz.add(new Point(900,467));
        waitingPointsParplatz.add(new Point(900,437));
        waitingPointsParplatz.add(new Point(900,407));
        waitingPointsParplatz.add(new Point(900,377));
        waitingPointsParplatz.add(new Point(900,347));
        waitingPointsParplatz.add(new Point(900,317));
        waitingPointsParplatz.add(new Point(900,287));
        waitingPointsParplatz.add(new Point(900,257));
        
        
        waitingPointsAusfahrt.add(new Point(514,257));
        waitingPointsAusfahrt.add(new Point(464,257));
        waitingPointsAusfahrt.add(new Point(434,276));
        waitingPointsAusfahrt.add(new Point(434,314));
        waitingPointsAusfahrt.add(new Point(434,356));
        waitingPointsAusfahrt.add(new Point(419,408));
        waitingPointsAusfahrt.add(new Point(374,408));
        
        waitingPointsBaustelle.add(new Point(293,426));
        
        einfahrt = new CarQueueDraw(waitingPointsEinfahrt, new Point(32,243));
        parkplatz = new CarQueueDraw(waitingPointsParplatz);
        ausfahrt = new CarQueueDraw(waitingPointsAusfahrt, new Point(452,204));
        baustelle = new CarQueueDraw(waitingPointsBaustelle);
       
        test = new ParcSimulation(toDraw,toDrawTL,0,0,0,0,0,0,"");

        
        toDraw.add(einfahrt);
        toDraw.add(parkplatz);
        toDraw.add(ausfahrt);
        toDraw.add(baustelle);
        this.toDrawTL.add(einfahrtAmpel);
        this.toDrawTL.add(ausfahrtAmpel);
        
        
          
        
        createInput();      
        createParcView();
        createAlgoChoose();
        createSpeedControl();
        createControl();
        
        
        Listener listener = new Listener() {
            private int simSpeed = 1000;
        public void handleEvent(Event event) {
            if (event.widget == buttonStart) {
              t = new Timer();
              this.simSpeed = 1000;
              t.schedule(new ParcSimulationThreaded(test),0,simSpeed);
              buttonStart.setEnabled(false);
              buttonStep.setEnabled(false);
              buttonStop.setEnabled(true);
              buttonx05.setEnabled(true);
              buttonx1.setEnabled(true);
              buttonx2.setEnabled(true);
              buttonx5.setEnabled(true);
              buttonx10.setEnabled(true);
              buttonx100.setEnabled(true);
            }
            if (event.widget == buttonStep) {
                    try {
                        t = new Timer();
                        t.schedule(new ParcSimulationThreaded(test), 0, 30);
                        Thread.sleep(10);
                        t.cancel();
                    } catch (InterruptedException ex) {
                        Logger.getLogger(MainFrame.class.getName()).log(Level.SEVERE, null, ex);
                    }
            }
            if(event.widget == buttonExit) {
              if(t != null)
                t.cancel();
              shell.dispose();
            }
            if(event.widget == buttonStop) {
              t.cancel();
              buttonStart.setEnabled(true);
              buttonStop.setEnabled(false);
              buttonStep.setEnabled(true);
              buttonx05.setEnabled(false);
              buttonx1.setEnabled(false);
              buttonx2.setEnabled(false);
              buttonx5.setEnabled(false);
              buttonx10.setEnabled(false);
              buttonx100.setEnabled(false);
            }
            if(event.widget == buttonInit) {
                buttonInit.setVisible(false);
                buttonStart.setEnabled(true);
                buttonStep.setEnabled(true);
                test = new ParcSimulation(toDraw,toDrawTL,Integer.valueOf(ta1.getText().trim()),Integer.valueOf(ta2.getText().trim()),Integer.valueOf(tb.getText().trim()),Integer.valueOf(n.getText().trim()),Integer.valueOf(te1.getText().trim()),Integer.valueOf(te2.getText().trim()),chooseAlgoCombo.getText());
                ta1.setVisible(false);
                ta2.setVisible(false);
                tb.setVisible(false);
                te2.setVisible(false);
                te1.setVisible(false);
                n.setVisible(false);
                parcView.init(toDraw, toDrawTL,test);
                buttonReInit.setVisible(true);
            }
            if(event.widget == buttonReInit) {
                if(t instanceof Timer)
                    t.cancel();
                buttonInit.setVisible(true);
                buttonStart.setEnabled(false);
                buttonStep.setEnabled(false);
                buttonStop.setEnabled(false);
                for(CarQueueDraw a : toDraw) {
                    a.waitingCars.clear();
                }
                for(TrafficLightDraw a : toDrawTL) {
                    a.enable(false);
                }
                test = new ParcSimulation(toDraw,toDrawTL,0,0,0,0,0,0,"");
                ta1.setVisible(true);
                ta2.setVisible(true);
                tb.setVisible(true);
                te2.setVisible(true);
                te1.setVisible(true);
                n.setVisible(true);
                buttonReInit.setVisible(false);
            }
            if(event.widget == buttonx05) {
              this.simSpeed = 2000;
              t.cancel();
              t = new Timer();
              t.schedule(new ParcSimulationThreaded(test),0,simSpeed);
            }
            if(event.widget == buttonx1) {
              t.cancel();
              t = new Timer();
              this.simSpeed = 1000;
              t.schedule(new ParcSimulationThreaded(test),0,simSpeed);
            }
            if(event.widget == buttonx2) {
                t.cancel();
              t = new Timer();
              this.simSpeed = 500;
              t.schedule(new ParcSimulationThreaded(test),0,simSpeed);
            }
            if(event.widget == buttonx5) {
                t.cancel();
              t = new Timer();
              this.simSpeed = 250;
              t.schedule(new ParcSimulationThreaded(test),0,simSpeed);
            }
            if(event.widget == buttonx10) {
                t.cancel();
              t = new Timer();
              this.simSpeed = 100;
              t.schedule(new ParcSimulationThreaded(test),0,simSpeed);
            }
            if(event.widget == buttonx100) {
                t.cancel();
              t = new Timer();
              this.simSpeed = 10;
              t.schedule(new ParcSimulationThreaded(test),0,simSpeed);
            }
          }
        };
        
        FocusListener focusListener = new FocusListener() {
          public void focusGained(FocusEvent e) {
            Text t = (Text) e.widget;
            t.selectAll();
          }

          public void focusLost(FocusEvent e) {
            Text t = (Text) e.widget;
            if (t.getSelectionCount() > 0) {
              t.clearSelection();
            }
          }
        };
        
        
        ta1.addFocusListener(focusListener);
        ta2.addFocusListener(focusListener);
        n.addFocusListener(focusListener);
        te1.addFocusListener(focusListener);
        te2.addFocusListener(focusListener);
        tb.addFocusListener(focusListener);
        buttonStart.addListener(SWT.Selection, listener);
        buttonExit.addListener(SWT.Selection, listener);
        buttonStop.addListener(SWT.Selection, listener);
        buttonInit.addListener(SWT.Selection, listener);
        buttonReInit.addListener(SWT.Selection, listener);
        buttonStep.addListener(SWT.Selection, listener);
        buttonx05.addListener(SWT.Selection, listener);
        buttonx1.addListener(SWT.Selection, listener);
        buttonx2.addListener(SWT.Selection, listener);
        buttonx5.addListener(SWT.Selection, listener);
        buttonx10.addListener(SWT.Selection, listener);
        buttonx100.addListener(SWT.Selection, listener);
        
        
        shell.open();
        while(!shell.isDisposed()) {
            if(!display.readAndDispatch()) {
            	display.sleep();
            }
            
           //this.display.setCursorLocation(this.display.getCursorLocation().x-1, this.display.getCursorLocation().y-1);
        }
    }
   
    private void createControl() {
        GridData gridData6 = new GridData();
	gridData6.horizontalAlignment = GridData.BEGINNING;
	gridData6.grabExcessHorizontalSpace = false;
	gridData6.horizontalIndent = 0;
	gridData6.horizontalSpan = 4;
	gridData6.verticalAlignment = GridData.CENTER;
	GridData gridData5 = new GridData();
	gridData5.horizontalAlignment = GridData.END;
	gridData5.grabExcessVerticalSpace = false;
	gridData5.grabExcessHorizontalSpace = false;
	gridData5.verticalAlignment = GridData.CENTER;
	GridData gridData4 = new GridData();
	gridData4.horizontalSpan = 5;
	gridData4.verticalAlignment = GridData.CENTER;
	gridData4.grabExcessHorizontalSpace = true;
	gridData4.horizontalAlignment = GridData.CENTER;
	GridLayout gridLayout = new GridLayout();
	gridLayout.numColumns = 5;
	gridLayout.verticalSpacing = 5;
	gridLayout.horizontalSpacing = 18;
	gridLayout.marginHeight = 5;
	gridLayout.makeColumnsEqualWidth = false;
	gridLayout.marginWidth = 5;
	GridData gridData2 = new GridData();
	gridData2.horizontalAlignment = GridData.CENTER;
	gridData2.grabExcessHorizontalSpace = false;
	gridData2.horizontalSpan = 5;
	gridData2.verticalAlignment = GridData.CENTER;
	GridData gridData = new GridData();
	gridData.grabExcessVerticalSpace = true;
	gridData.verticalAlignment = GridData.END;
	gridData.grabExcessHorizontalSpace = false;
	gridData.horizontalAlignment = GridData.CENTER;
        
        control = new Group(shell, SWT.NONE);
	control.setLayoutData(gridData);
	control.setLayout(gridLayout);
	control.setText("Simulation Control");
        
        buttonStart = new Button(control, SWT.PUSH);
        buttonStart.setBounds(0, 0, 50, 20);
        buttonStart.setText("START");
        buttonStart.setEnabled(false);
        buttonStep = new Button(control, SWT.PUSH);
        buttonStep.setBounds(0, 0, 50, 20);
        buttonStep.setText("STEP");
        buttonStep.setEnabled(false);
        buttonStop = new Button(control, SWT.PUSH);
        buttonStop.setBounds(0, 0, 50, 20);
        buttonStop.setText("STOP");
        buttonStop.setEnabled(false);
        buttonExit = new Button(control, SWT.PUSH);
        buttonExit.setBounds(0, 0, 50, 20);
        buttonExit.setText("EXIT");
    }

    private void createInput() {
        GridData gridData3 = new GridData();
	gridData3.horizontalSpan = 5;
	gridData3.verticalAlignment = GridData.CENTER;
	gridData3.grabExcessVerticalSpace = false;
	gridData3.horizontalAlignment = GridData.CENTER;
	GridLayout gridLayout1 = new GridLayout();
	gridLayout1.numColumns = 4;
	gridLayout1.verticalSpacing = 5;
	gridLayout1.makeColumnsEqualWidth = false;
	gridLayout1.marginWidth = 5;
	GridData gridData1 = new GridData();
	gridData1.horizontalAlignment = GridData.CENTER;
	gridData1.grabExcessHorizontalSpace = false;
	gridData1.verticalAlignment = GridData.CENTER;
	input = new Group(shell, SWT.NONE);
	input.setLayoutData(gridData1);
	input.setLayout(gridLayout1);
	input.setText("Input in Minuten");
        
        ta1Label = new Label(input,SWT.NONE);
        ta1Label.setText("ta1");
        ta1 = new Text(input, SWT.WRAP | SWT.BORDER);
        ta1.setBounds(100, 50, 100, 20);
        ta1.setTextLimit(5);
        ta1.setText(" 5   ");
        ta2Label = new Label(input,SWT.NONE);
        ta2Label.setText("ta2");
        ta2 = new Text(input, SWT.WRAP | SWT.BORDER);
        ta2.setBounds(100, 50, 100, 20);
        ta2.setTextLimit(5);
        ta2.setText(" 15   ");
        tbLabel = new Label(input,SWT.NONE);
        tbLabel.setText("tb");
        tb = new Text(input, SWT.WRAP | SWT.BORDER);
        tb.setBounds(100, 50, 100, 20);
        tb.setTextLimit(5);
        tb.setText(" 5   ");
        nLabel = new Label(input,SWT.NONE);
        nLabel.setText("n");
        n = new Text(input, SWT.WRAP | SWT.BORDER);
        n.setBounds(100, 50, 100, 20);
        n.setTextLimit(5);
        n.setText(" 20  ");
        te1Label = new Label(input,SWT.NONE);
        te1Label.setText("te1");
        te1 = new Text(input, SWT.WRAP | SWT.BORDER);
        te1.setBounds(100, 50, 100, 20);
        te1.setTextLimit(5);
        te1.setText(" 60   ");
        te2Label = new Label(input,SWT.NONE);
        te2Label.setText("te2");
        te2 = new Text(input, SWT.WRAP | SWT.BORDER);
        te2.setBounds(100, 50, 100, 20);
        te2.setTextLimit(5);
        te2.setText(" 180 ");
        
        buttonInit = new Button(input, SWT.PUSH);
        buttonInit.setBounds(0, 0, 50, 20);
        buttonInit.setText("INITIALIZE");
        buttonReInit = new Button(input, SWT.PUSH);
        buttonReInit.setBounds(0, 0, 50, 20);
        buttonReInit.setText("RE-INITIALIZE");
        buttonReInit.setVisible(false);
    }
    
    private void createShell() {
        display = new Display();
        GridLayout gridLayout2 = new GridLayout();
	gridLayout2.numColumns = 2;
	gridLayout2.marginWidth = 15;
        gridLayout2.marginHeight = 15;
	gridLayout2.horizontalSpacing = 10;
	shell = new Shell(display,SWT.TITLE | SWT.CLOSE | SWT.BORDER);
	shell.setText("ParcView");
        shell.setLayout(gridLayout2);
        shell.setSize(new Point(1300, 780));
        
        
    }
    
    private void createParcView()  throws FileNotFoundException, IOException{

        GridData gridData7 = new GridData();
	gridData7.horizontalAlignment = GridData.FILL;
	gridData7.grabExcessHorizontalSpace = true;
	gridData7.grabExcessVerticalSpace = true;
	gridData7.verticalSpan = 4;
	gridData7.verticalAlignment = GridData.FILL;
	parcView = new ParcView(shell, SWT.DOUBLE_BUFFERED, test);
        parcView.init(toDraw, toDrawTL,test);
	parcView.setLayoutData(gridData7);
        
    }

    private void createSpeedControl() {
        GridData gridData6 = new GridData();
	gridData6.horizontalAlignment = GridData.BEGINNING;
	gridData6.grabExcessHorizontalSpace = false;
	gridData6.horizontalIndent = 0;
	gridData6.horizontalSpan = 4;
	gridData6.verticalAlignment = GridData.CENTER;
	GridData gridData5 = new GridData();
	gridData5.horizontalAlignment = GridData.END;
	gridData5.grabExcessVerticalSpace = false;
	gridData5.grabExcessHorizontalSpace = false;
	gridData5.verticalAlignment = GridData.CENTER;
	GridData gridData4 = new GridData();
	gridData4.horizontalSpan = 5;
	gridData4.verticalAlignment = GridData.CENTER;
	gridData4.grabExcessHorizontalSpace = true;
	gridData4.horizontalAlignment = GridData.CENTER;
	GridLayout gridLayout = new GridLayout();
	gridLayout.numColumns = 5;
	gridLayout.verticalSpacing = 5;
	gridLayout.horizontalSpacing = 18;
	gridLayout.marginHeight = 5;
	gridLayout.makeColumnsEqualWidth = false;
	gridLayout.marginWidth = 5;
	GridData gridData2 = new GridData();
	gridData2.horizontalAlignment = GridData.CENTER;
	gridData2.grabExcessHorizontalSpace = false;
	gridData2.horizontalSpan = 5;
	gridData2.verticalAlignment = GridData.CENTER;
	GridData gridData = new GridData();
	gridData.grabExcessVerticalSpace = true;
	gridData.verticalAlignment = GridData.END;
	gridData.grabExcessHorizontalSpace = false;
	gridData.horizontalAlignment = GridData.CENTER;
        
        speed = new Group(shell, SWT.NONE);
	speed.setLayoutData(gridData);
	speed.setLayout(gridLayout);
	speed.setText("Speed Control");
        
        buttonx05 = new Button(speed, SWT.PUSH);
        buttonx05.setBounds(0, 0, 50, 20);
        buttonx05.setText("x0.5");
        buttonx05.setEnabled(false);
        buttonx1 = new Button(speed, SWT.PUSH);
        buttonx1.setBounds(0, 0, 50, 20);
        buttonx1.setText("Normal");
        buttonx1.setEnabled(false);
        buttonx2 = new Button(speed, SWT.PUSH);
        buttonx2.setBounds(0, 0, 50, 20);
        buttonx2.setText("x2");
        buttonx2.setEnabled(false);
        buttonx5 = new Button(speed, SWT.PUSH);
        buttonx5.setBounds(0, 0, 50, 20);
        buttonx5.setText("x5");
        buttonx5.setEnabled(false);
        buttonx10 = new Button(speed, SWT.PUSH);
        buttonx10.setBounds(0, 0, 50, 20);
        buttonx10.setText("x10");
        buttonx10.setEnabled(false);
        buttonx100 = new Button(speed, SWT.PUSH);
        buttonx100.setBounds(0, 0, 50, 20);
        buttonx100.setText("x100");
        buttonx100.setEnabled(false);
    }
    
    private void createAlgoChoose() {
        GridData gridData6 = new GridData();
	gridData6.horizontalAlignment = GridData.BEGINNING;
	gridData6.grabExcessHorizontalSpace = false;
	gridData6.horizontalIndent = 0;
	gridData6.horizontalSpan = 4;
	gridData6.verticalAlignment = GridData.CENTER;
	GridData gridData5 = new GridData();
	gridData5.horizontalAlignment = GridData.END;
	gridData5.grabExcessVerticalSpace = false;
	gridData5.grabExcessHorizontalSpace = false;
	gridData5.verticalAlignment = GridData.CENTER;
	GridData gridData4 = new GridData();
	gridData4.horizontalSpan = 5;
	gridData4.verticalAlignment = GridData.CENTER;
	gridData4.grabExcessHorizontalSpace = true;
	gridData4.horizontalAlignment = GridData.CENTER;
	GridLayout gridLayout = new GridLayout();
	gridLayout.numColumns = 5;
	gridLayout.verticalSpacing = 5;
	gridLayout.horizontalSpacing = 18;
	gridLayout.marginHeight = 5;
	gridLayout.makeColumnsEqualWidth = false;
	gridLayout.marginWidth = 5;
	GridData gridData2 = new GridData();
	gridData2.horizontalAlignment = GridData.CENTER;
	gridData2.grabExcessHorizontalSpace = false;
	gridData2.horizontalSpan = 5;
	gridData2.verticalAlignment = GridData.CENTER;
	GridData gridData = new GridData();
	gridData.grabExcessVerticalSpace = true;
	gridData.verticalAlignment = GridData.END;
	gridData.grabExcessHorizontalSpace = false;
	gridData.horizontalAlignment = GridData.CENTER;
        
        algo = new Group(shell, SWT.NONE);
	algo.setLayoutData(gridData);
	algo.setLayout(gridLayout);
	algo.setText("Algorithmen Auswahl");
        
        chooseAlgoCombo = new Combo(algo, SWT.NONE);
        chooseAlgoCombo.setItems (Algorithm.getAlgoList());
	chooseAlgoCombo.setSize (200, 200);
        chooseAlgoCombo.setText(Algorithm.getAlgoList()[0]);
    }
}